//
//  AppDelegate.m
//  RTMLibDemo
//
//  Created by reyzhang on 2022/1/5.
//

#import "AppDelegate.h"
#import <YMRTMLib/YMRTMLib.h>
#import "LoginViewController.h"
#import "HomeViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(enterMain:) name:@"enterMain" object:nil];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(showLoginVC) name:@"login" object:nil];
    
    NSAssert(kYMAppKey.length > 0, @"请先配置译码小二郎 AppKey");
    NSAssert(kYMAppSecret.length > 0, @"请先配置译码小二郎 AppSecret");
    [YMRTMClient registerAppKey:kYMAppKey appSecret:kYMAppSecret];
    
    [self showLoginVC];
    [self.window makeKeyAndVisible];
    
    return YES;
}


- (void)showLoginVC {
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    LoginViewController *vc = [sb instantiateViewControllerWithIdentifier:@"LoginViewController"];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    
    self.window.rootViewController = nav;
}

- (void)enterMain:(NSNotification *)notif {
    
    HomeViewController *vc = [[HomeViewController alloc] init];
    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:vc];
    self.window.rootViewController = nav;
}



@end
